package ru.maksb.exchange.client;

import static ru.maksb.exchange.utils.PrintUtil.*;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.concurrent.BlockingQueue;

public class InputHandler {
    private ObjectInputStream in;
    private BlockingQueue<String> messages;

    public InputHandler(ObjectInputStream in, BlockingQueue<String> messages) {
        this.in = in;
        this.messages = messages;
    }

    public void run() {
        String message = null;
        try {
            do {
                message = (String) in.readObject();
                serverSysout(message);
            } while (!"bye".equals(message));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
